import Vue from 'vue'
import Vuex from 'vuex'
import httpAxios from '../until/httpAxios'
import api   from '../public/api'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userData:{
      allPerson:0,
      todayPerson:0,
      allRealPerson:0
    },
    orderData:{
      allOder:0,
      todayOrder:0
    }
  },
  mutations: {

    // 修改注册用户数据
    changeuserData(state,actions){
     state.userData  = {...actions.userData}
    },

    // 修改我们的订单数据
    changeOrderData(state,actions){
      state.orderData  = {...actions.orderData}
     },
  },
  
  actions: {
    // 用于在仓库中发起数据请求 
    initData(store){
      httpAxios(api.GET_WORK_DATA(),res=>{
        const {userData,orderData} = res.data;
          store.commit('changeuserData',{userData})
          store.commit('changeOrderData',{orderData})

      })
  }
      
  },
  modules: {
  }
})
